package com.xue.my.protocol;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xue.my.util.spring.SpringContextHolder;

/**   
 * @Title: ProtocolCodecFilter.java 
 * @Package com.xue.my.protocol 
 * @Description: TODO
 * @author jimmy lovelyxuehanxin@163.com   
 * @date 2013-7-13 8:38:59 
 */
public class ProtocolCodecFilter {
	
	private static MessageCodecFactory messageCodecFactory = SpringContextHolder.getBean(MessageCodecFactory.class);

	public static AbstractMessage encodeResponse(ModelAndView mv, HttpServletRequest request,HttpServletResponse response){
		MessageEncoder messageEncoder = messageCodecFactory.getMessageEncoderCodec(request);
 		return messageEncoder.messageEncode(mv.getResponseMap(), request, response);
	}
	public static AbstractMessage decodeRequest(HttpServletRequest request,HttpServletResponse response){
		MessageDecoder messageDecoder = messageCodecFactory.getMessageDecoderCodec(request);
		return messageDecoder.messageDecode(request, response);
	}
}
